package br.ufrgs.tcp;


import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import br.ufrgs.tcp.maps.base.IMapAdapter;

public class SearchFragment extends Fragment {

	private Cursor data;
	private IMapAdapter map;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.search, container,false);
		EditText edtText = (EditText) v.findViewById(R.id.editText1);
		edtText.setOnEditorActionListener(new OnEditorActionListener() {

			@Override
			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
				if (actionId == EditorInfo.IME_ACTION_DONE)
					SearchController.performSearch(v.getText().toString(), getActivity());
				return false;
			}
		});

		return v;
	}	



	void updateMap() {
		this.map.updateMap(data);

	}

}
